import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel, GetUserInfoModel ,codeInfo} from './model/userModel';

import { ErrorMessageMode } from '/#/axios';

enum Api {
  Login = '/auth/login',
  code = '/code',
  GetUserInfo = '/getUserInfo',
  GetPermCode = '/getPermCode',
  Getpw = '/auth/passwordValidate',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<LoginResultModel>(
    {
      url: Api.Login,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/*
*  获取验证码
* */

export function codeApi() {
  return defHttp.get<codeInfo>({ url: Api.code });
}

/**
 * @description: getUserInfo
 */
export function getUserInfo() {
  return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo });
}

export function getPermCode() {
  return defHttp.get<string[]>({ url: Api.GetPermCode });
}
export function getPw(password?:string) {
  return defHttp.post({
    url: Api.Getpw,
    params:{'password':password}
  },{isTransformResponse:false});
}
